package com.android.bonn.fast;

import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;

import androidx.annotation.NonNull;

import com.android.bonn.fast.adapter.CellView;
import com.android.bonn.fast.databinding.ItemViewLayout2Binding;

public class JavaCellView extends CellView<InnerFromView> {

    private ItemViewLayout2Binding binding;
    private AnyAdapterListActivity.FormData formData;

    public JavaCellView(@NonNull View view, AnyAdapterListActivity.FormData formData) {
        super(view);
        this.formData = formData;
        binding = ItemViewLayout2Binding.bind(view);
    }

    @Override
    public void onBind(InnerFromView data, int position) {
        binding.title.setText(data.getTitle());
        binding.text.setHint(data.getHintText());
        binding.text.setText(formData.getCustomCat());

        binding.text.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void afterTextChanged(Editable editable) {
                formData.setCustomCat(editable.toString());
            }
        });
    }
}
